package com.ssy.lingxi.order.controller.web;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.order.model.vo.basic.request.OrderProcessIdVO;
import com.ssy.lingxi.order.model.vo.basic.request.OrderProcessUpdateStatusVO;
import com.ssy.lingxi.order.model.vo.process.request.OrderProcessNamePageVO;
import com.ssy.lingxi.order.model.vo.process.request.OrderTradeProcessProductPageVO;
import com.ssy.lingxi.order.model.vo.process.request.OrderTradeProcessUpdateVO;
import com.ssy.lingxi.order.model.vo.process.request.OrderTradeProcessVO;
import com.ssy.lingxi.order.model.vo.process.response.BaseTradeProcessVO;
import com.ssy.lingxi.order.model.vo.process.response.OrderProcessPageQueryVO;
import com.ssy.lingxi.order.model.vo.process.response.OrderTradeProcessDetailVO;
import com.ssy.lingxi.order.model.vo.process.response.OrderTradeProcessProductQueryVO;
import com.ssy.lingxi.order.service.web.IOrderTradeProcessService;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @menu 系统能力 - 交易流程规则配置相关接口
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-25
 */
@RestController
@RequestMapping("/order/trade/process")
public class OrderTradeProcessController {
    @Resource
    private IOrderTradeProcessService orderTradeProcessService;

    /**
     * 分页查询交易流程规则
     * @param headers HttpHeaders信息
     * @param pageVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/page", method = RequestMethod.GET)
    public Wrapper<PageData<OrderProcessPageQueryVO>> pageTradeProcesses(@RequestHeader HttpHeaders headers, @Valid OrderProcessNamePageVO pageVO) {
        return orderTradeProcessService.pageTradeProcesses(headers, pageVO);
    }

    /**
     * 新增交易规则页面 - 查询基础交易流程列表
     * @param headers Http头部信息
     * @return 查询结果
     */
    @RequestMapping(value = "/base/list", method = RequestMethod.GET)
    public Wrapper<List<BaseTradeProcessVO>> listBaseTradeProcess(@RequestHeader HttpHeaders headers) {
        return orderTradeProcessService.listBaseTradeProcess(headers);
    }

    /**
     * 新增交易流程规则
     * @param headers HttpHeaders信息
     * @param processVO 接口参数
     * @return 新增结果
     */
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public Wrapper<Void> createTradeProcess(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderTradeProcessVO processVO) {
        return orderTradeProcessService.createTradeProcess(headers, processVO);
    }

    /**
     * 查询交易流程规则详情
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public Wrapper<OrderTradeProcessDetailVO> getTradeProcess(@RequestHeader HttpHeaders headers, @Valid OrderProcessIdVO idVO) {
        return orderTradeProcessService.getTradeProcess(headers, idVO);
    }

    /**
     * 分页查询交易流程规则适用商品列表
     * @param headers HttpHeaders信息
     * @param pageVO  接口参数
     * @return 查询结果
     */
    @RequestMapping(value = "/product/page", method = RequestMethod.GET)
    public Wrapper<PageData<OrderTradeProcessProductQueryVO>> pageTradeProcessProducts(@RequestHeader HttpHeaders headers, @Valid OrderTradeProcessProductPageVO pageVO) {
        return orderTradeProcessService.pageTradeProcessProducts(headers, pageVO);
    }

    /**
     * 修改交易流程规则
     * @param headers HttpHeaders信息
     * @param updateVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    public Wrapper<Void> updateTradeProcess(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderTradeProcessUpdateVO updateVO) {
        return orderTradeProcessService.updateTradeProcess(headers, updateVO);
    }

    /**
     * 修改交易流程规则状态
     * @param headers HttpHeaders信息
     * @param statusVO 接口参数
     * @return 修改结果
     */
    @RequestMapping(value = "/status/update", method = RequestMethod.POST)
    public Wrapper<Void> updateTradeProcessStatus(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderProcessUpdateStatusVO statusVO) {
        return orderTradeProcessService.updateTradeProcessStatus(headers, statusVO);
    }

    /**
     * 删除交易流程规则
     * @param headers HttpHeaders信息
     * @param idVO 接口参数
     * @return 删除结果
     */
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    public Wrapper<Void> deleteTradeProcess(@RequestHeader HttpHeaders headers, @RequestBody @Valid OrderProcessIdVO idVO) {
        return orderTradeProcessService.deleteTradeProcess(headers, idVO);
    }
}
